﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MrPP.SerriedCabinet
{
    public class CellShelve : MonoBehaviour
    {
        [SerializeField]
        private CellShelveUI _ui;
        public void setText(string text) {
            _ui.setText(text);
        }

        [SerializeField]
        private Location _location;
        public void selected(Location location)
        {
            if (ShelveModel.IsInitialized)
            {
                ShelveModel.Instance.doSelected(location.location);
            }
        }

        internal void reset()
        {
            _ui.setText("");
        }

        [SerializeField]
        private GameObject _core;
        void Start() {
            close();
        }
        internal void close()
        {
            _core.SetActive(false);
            _ui.gameObject.SetActive(false);
        }

        internal void open()
        {

            if (_location.location.type == Box.Type.Left)
            {

                _ui.transform.localEulerAngles = new Vector3(0, 0, 0);
            }
            else
            {

                _ui.transform.localEulerAngles = new Vector3(0, 180, 0);
            }
            _core.SetActive(true);
            _ui.gameObject.SetActive(true);
        }
    }
}